package com.qfedu.controller;

import com.qfedu.pojo.req.OrderReq;
import com.qfedu.pojo.req.OrdersReq;
import com.qfedu.pojo.resp.BaseResp;
import com.qfedu.pojo.resp.OrdersResp;
import com.qfedu.service.OrderService;
import com.qfedu.service.OrdersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author:User
 * @time:2022/9/27
 * @explain:
 */
@RestController
@RequestMapping("/orders")
public class OrdersServlet {

    @Autowired
    private OrdersService ordersService;

    /**
     * 生成订单
     * @return
     */
    @PostMapping ("/addOrders")
    public BaseResp addOrders(@RequestBody OrdersReq ordersReq){
        BaseResp baseResp = ordersService.addOrders(ordersReq);
        return baseResp;
    }
    /**
     * 查询订单
     */
    @PostMapping ("/findByUserId")
    public BaseResp findByUserId(@RequestBody OrdersReq ordersReq){
        BaseResp byUserId = ordersService.findByUserId(ordersReq);
        return byUserId;
    }

    /**
     * 修改订单
     */
    @PostMapping ("/updateOrders")
    public BaseResp updateOrders(@RequestBody OrdersReq ordersReq){
        BaseResp baseResp = ordersService.updateOrders(ordersReq);
        return baseResp;
    }

}
